{%- extends "base.html" %}

{%- block title %}
{% trans %}Domain details{% endtrans %}
{%- endblock %}

{%- block subtitle %}
{{ domain.name }}
{%- endblock %}

{%- block main_action %}
{%- if current_user.global_admin %}
<a class="btn btn-primary btn-group float-right" href="{{ url_for(".domain_genkeys", domain_name=domain.name) }}">
  {%- if domain.dkim_publickey %}
  {% trans %}Regenerate keys{% endtrans %}
  {%- else %}
  {% trans %}Generate keys{% endtrans %}
  {%- endif %}
</a><a style="margin-right: 5px;" class="btn btn-primary btn-group float-right" href="{{ url_for(".domain_download_zonefile", domain_name=domain.name) }}">  {% trans %}Download zonefile{% endtrans %}</a>
{%- endif %}
{%- endblock %}

{%- block content %}
{%- call macros.table(datatable=False) %}
<tr>
  <th>{% trans %}Domain name{% endtrans %}</th>
  <td>{{ domain.name }}</td>
</tr>
<tr>
  <th>{% trans %}DNS MX entry{% endtrans %} <i class="fa {{ 'fa-check-circle text-success' if domain.check_mx() else 'fa-exclamation-circle text-danger' }}"></i></th>
  <td>{{ macros.clip("dns_mx") }}<pre id="dns_mx" class="pre-config border bg-light">{{ domain.dns_mx }}</pre></td>
</tr>
<tr>
  <th>{% trans %}DNS SPF entries{% endtrans %}</th>
  <td>{{ macros.clip("dns_spf") }}<pre id="dns_spf" class="pre-config border bg-light">{{ domain.dns_spf }}</pre>
  </td>
</tr>
{%- if domain.dkim_publickey %}
<tr>
  <th>{% trans %}DNS DKIM entry{% endtrans %}</th>
  <td>{{ macros.clip("dns_dkim") }}<pre id="dns_dkim" class="pre-config border bg-light">{{ domain.dns_dkim }}</pre></td>
</tr>
<tr>
  <th>{% trans %}DNS DMARC entry{% endtrans %}</th>
  <td>
    {{ macros.clip("dns_dmarc") }}<pre id="dns_dmarc" class="pre-config border bg-light">{{ domain.dns_dmarc }}</pre>
    {%- if domain.dns_dmarc_report_needed %}
    {{ macros.clip("dns_dmarc_report") }}<pre id="dns_dmarc_report" class="pre-config border bg-light">{{ domain.dns_dmarc_report }}</pre>
    {%- endif %}
  </td>
</tr>
{%- endif %}
{%- if domain.dns_tlsa|length > 0 %}
<tr>
  <th>{% trans %}DNS TLSA entry{% endtrans %}</br><span class="text-secondary text-xs font-weight-normal">Let's Encrypt ISRG Roots</span></th>
  <td>{{ macros.clip("dns_tlsa") }}<pre id="dns_tlsa" class="pre-config border bg-light">{{ domain.dns_tlsa | join("\n") }}</pre></td>
</tr>
{%- endif %}
<tr>
  <th>{% trans %}DNS client auto-configuration entries{% endtrans %}</th>
  <td>{{ macros.clip("dns_autoconfig") }}<pre id="dns_autoconfig" class="pre-config border bg-light">
{%- for line in domain.dns_autoconfig %}
{{ line }}
{%- endfor -%}
  </pre></td>
</tr>
{%- endcall %}

{%- for alternative in domain.alternatives %}

{%- call macros.table(datatable=False) %}
<tr>
  <th>{% trans %}Alternative Domain name{% endtrans %}</th>
  <td>{{ alternative.name }}</td>
</tr>
<tr>
  <th>{% trans %}DNS MX entry{% endtrans %} <i class="fa {{ 'fa-check-circle text-success' if alternative.check_mx() else 'fa-exclamation-circle text-danger' }}"></i></th>
  <td>{{ macros.clip("dns_mx") }}<pre id="dns_mx" class="pre-config border bg-light">{{ alternative.dns_mx }}</pre></td>
</tr>
<tr>
  <th>{% trans %}DNS SPF entries{% endtrans %}</th>
  <td>{{ macros.clip("dns_spf") }}<pre id="dns_spf" class="pre-config border bg-light">{{ alternative.dns_spf }}</pre>
  </td>
</tr>
{%- if alternative.domain.dkim_publickey %}
<tr>
  <th>{% trans %}DNS DKIM entry{% endtrans %}</th>
  <td>{{ macros.clip("dns_dkim") }}<pre id="dns_dkim" class="pre-config border bg-light">{{ alternative.dns_dkim }}</pre></td>
</tr>
<tr>
  <th>{% trans %}DNS DMARC entry{% endtrans %}</th>
  <td>
    {{ macros.clip("dns_dmarc") }}<pre id="dns_dmarc" class="pre-config border bg-light">{{ alternative.dns_dmarc }}</pre>
    {%- if alternative.dns_dmarc_report_needed %}
    {{ macros.clip("dns_dmarc_report") }}<pre id="dns_dmarc_report" class="pre-config border bg-light">{{ alternative.dns_dmarc_report }}</pre>
    {%- endif %}
  </td>
</tr>
{%- endif %}
{%- endcall %}
{%- endfor %}
{%- endblock %}
